local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script,script.Parent.Base);
local ConnectClass=_G.CommonOHOH.load.Connect();

-- 轮胎
function M.new(...)
	return M(...);
end;

function M.ctor(self,...)--构造函数
	M.super.ctor(self,...);


	--body更新，点位发生变化，自己也得更新
	self.Car.BodyUpdateEvent:Connect(function()
			if self.CarId then
				self:Update(self.CarId)
			end
	end)
	
end;

function M.dtor(self)
	M.super.dtor(self);
end;



--组装到整车上（子类实现）
function M.Assemble(self)
	self.Body=self.Car:GetBody()
	
	self.Instance.Name= "Tail"
	self.Instance:PivotTo(self.Body:GetTailPivot())
	local children = self.Instance:GetChildren()
	self.Emitter = children
	for _, child in pairs(children) do
		if child then
			if child.Name ~= "Instance"  then
				self:Weld2Part(child,self.Instance)
			end
		end
	end
    self:Weld2Part(self.Instance,self.Body:GetInstance())
    self.Instance.Parent=self.Body:GetInstance()

end

--设置发射器状态 true为开 false为关
function M.SetEmitterStatus(self,status)
	-- 需要实现
	for _, child in pairs(self.Emitter) do
		local Emitters= child:GetChildren()
		for _, Echild in pairs(Emitters) do
			if Echild then
				if Echild.ClassName == "ParticleEmitter"  then
					Echild.Enabled = status
				end
			end
		end
	end
end

function M.SetForwardSpeed(self,speed)
	-- 需要实现
	
end

-- 获取组装到车上的实例（子类实现）
function M.GetInstance(self)
	return self.Instance
end
return M